package nz.ac.massey.doi_information_extractor.tests;

import static org.junit.Assert.assertTrue;

import java.net.Authenticator;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import nz.ac.massey.doi_information_extractor.data.Publication;
import nz.ac.massey.doi_information_extractor.parser.SpringerExportPlugin;

import org.junit.Before;
import org.junit.Test;

public class SpringerExportPluginTest {

	Publication newpub;

	@Before
	public void setUp() throws Exception{
		System.setProperty("http.proxyHost", "tur-cache.massey.ac.nz");
		System.setProperty("http.proxyPort", "8080");
		Authenticator.setDefault(new TestAuthenticator());

		ExecutorService pool = Executors.newFixedThreadPool(1);
		Callable<Publication> springerExportPlugin = new SpringerExportPlugin("http://dx.doi.org/10.1007/s00348-003-0689-7");
		Future<Publication> futurespringerExportPluginResult = pool.submit(springerExportPlugin);

		newpub = futurespringerExportPluginResult.get();
	}

	@Test
	public void tests() {
		
		assertTrue(newpub.getAuthors().size() == 8);
		
		assertTrue(newpub.getAuthors().get(0).getAuthorLastName().equals("Raffel") && newpub.getAuthors().get(7).getAuthorLastName().equals("Pengel"));
		
		assertTrue(newpub.getArticleTitle().equals("Recording and evaluation methods of PIV investigations on a helicopter rotor model"));
		
		assertTrue(newpub.getPublicationTitle().equals("Experiments in Fluids"));
		
		assertTrue(newpub.getPageNumbers().equals("146-156"));
		
		assertTrue(newpub.getVolumeNumber().equals("36"));
		
		assertTrue(newpub.getEdition().equals("1"));
		
		assertTrue(newpub.getIssn().equals("0723-4864"));
		
		assertTrue(newpub.getPublisher().equals("Springer Berlin / Heidelberg"));
		
		assertTrue(newpub.getDescription().startsWith("Three-component particle image velocimetry") && newpub.getDescription().endsWith("and analysis of vortical flows."));
		
		
	}
}